package org.anderground.app;

import java.util.Set;

import org.anderground.core.model.City;
import org.anderground.core.model.Description;
import org.anderground.core.model.Hub;
import org.anderground.core.model.Line;
import org.anderground.core.model.ModelData;
import org.anderground.core.model.Station;
import org.anderground.core.model.Transfer;
import org.anderground.core.model.Tunnel;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

/**
 * @author Eldar Abusalimov
 */
public class MapInfoDialog extends AlertDialog {

	/**
	 * @param context
	 */
	public MapInfoDialog(Context context) {
		super(context);
		setTitle("Map info");
		setButton("Hide", new OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
			}
		});
	}

	/**
	 * Prepares the dialog to show an actual information
	 * 
	 * @param modelData
	 */
	public void prepare(ModelData modelData) {
		Set<Station> stations = modelData.getStations();
		Set<Line> lines = modelData.getLines();
		Set<Hub> hubs = modelData.getHubs();
		Set<Tunnel> tunnels = modelData.getTunnels();
		Set<Transfer> transfers = modelData.getTransfers();
		Description description = modelData.getDescription();
		City city = modelData.getCity();

		String message = "";
		message += "City name: ";
		if (city.getName().length() == 0) {
			message += "not presented";
		} else {
			message += city.getName();
		}
		message += "\n";
		message += "Authors:\n";
		if (description.getAuthors().size() == 0) {
			message += "   not presented\n";
		} else {
			for (String author : description.getAuthors()) {
				message += "   " + author + "\n";
			}
		}
		message += "Comment: ";
		if (description.getComment().length() == 0) {
			message += "not presented";
		} else {
			message += description.getComment();
		}
		message += "\n";
		message += "Model statistics:\n";
		message += "   stations: " + stations.size() + "\n";
		message += "   lines: " + lines.size() + "\n";
		message += "   hubs: " + hubs.size() + "\n";
		message += "   tunnels: " + tunnels.size() + "\n";
		message += "   transfers: " + transfers.size() + "\n";

		setMessage(message);
	}

}
